package com.design.command;

import java.util.ArrayList;

/**
 * @author leali
 * @title: CommandQueue
 * @projectName design
 * @description: 名利队列实现
 * @date 2022/1/3 17:07
 */
public class CommandQueue {
    private final ArrayList<Command> commands = new ArrayList<>();

    public void addCommand(Command command) {
        commands.add(command);
    }

    public void removeCommand(Command command) {
        commands.remove(command);
    }

    public void execute() {
        for (Command command : commands) {
            command.execute();
        }
    }
}
